﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JULONG.WEB.Library.Account
{
    public class routeItem
    {
        string _value;

        public string value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
            }
        }

        public routeItem(string value)
        {
            _value = value;
        }

        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        /// <summary>
        /// 等于号重载
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static implicit operator routeItem(string value)
        {
            return new routeItem(value);
        }

        /// <summary>
        /// 等于号重载
        /// </summary>
        /// <param name="routeItem"></param>
        /// <returns></returns>
        public static implicit operator string(routeItem routeItem)
        {
            return routeItem._value;
        }

        /// <summary>
        /// == 运算符重载
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static bool operator ==(routeItem left, routeItem right)
        {
            if (Equals(left, right))
                return true;

            if (left.value == "*")
                return true;

            if (right.value == "*")
                return true;

            if (String.Compare(left.value, right.value, true) == 0)
                return true;

            return false;
        }


        /// <summary>
        /// != 运算符重载
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static bool operator !=(routeItem left, routeItem right)
        {
            if (Equals(left, right))
                return false;

            if (left.value == "*")
                return false;

            if (right.value == "*")
                return false;

            if (String.Compare(left.value, right.value, true) == 0)
                return false;

            return true;
        }

    }
}
